package com.lenovo.lcdm.type.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lenovo.lcdm.common.enums.DeleteFlagEnum;
import com.lenovo.lcdm.type.entity.TypeLocalAttributeLink;
import com.lenovo.lcdm.type.mapper.TypeLocalAttributeLinkMapper;
import com.lenovo.lcdm.type.service.TypeLocalAttributeLinkService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
* @author xujing30
* @description 针对表【type_local_attribute_link】的数据库操作Service实现
* @createDate 2024-01-03 16:33:19
*/
@Service
public class TypeLocalAttributeLinkServiceImpl extends ServiceImpl<TypeLocalAttributeLinkMapper, TypeLocalAttributeLink>
    implements TypeLocalAttributeLinkService{

    @Override
    public List<TypeLocalAttributeLink> queryByTypeId(Long typeId) {
        LambdaQueryWrapper<TypeLocalAttributeLink> typeLocalAttributeLinkQw = new LambdaQueryWrapper<>();
        typeLocalAttributeLinkQw.eq(TypeLocalAttributeLink::getTypeId, typeId).eq(TypeLocalAttributeLink::getDeleted, DeleteFlagEnum.NO.getValue());
        return list(typeLocalAttributeLinkQw);
    }

    @Override
    public List<TypeLocalAttributeLink> queryByTypeIdBatch(List<Long> typeIds) {
        LambdaQueryWrapper<TypeLocalAttributeLink> typeLocalAttributeLinkQw = new LambdaQueryWrapper<>();
        typeLocalAttributeLinkQw.in(TypeLocalAttributeLink::getTypeId, typeIds).eq(TypeLocalAttributeLink::getDeleted, DeleteFlagEnum.NO.getValue());
        return list(typeLocalAttributeLinkQw);
    }

    @Override
    public TypeLocalAttributeLink queryByLocalAttributeId(Long localAttributeId) {
        LambdaQueryWrapper<TypeLocalAttributeLink> typeLocalAttributeLinkQw = new LambdaQueryWrapper<>();
        typeLocalAttributeLinkQw.eq(TypeLocalAttributeLink::getLocalAttributeId, localAttributeId).eq(TypeLocalAttributeLink::getDeleted, DeleteFlagEnum.NO.getValue());
        List<TypeLocalAttributeLink> list = list(typeLocalAttributeLinkQw);
        if(!CollectionUtils.isEmpty(list)){
            return list.get(0);
        }
        return null;
    }

    @Override
    public List<TypeLocalAttributeLink> findByLocalAttributeIdIn(List<Long> localAttributeIds) {
        LambdaQueryWrapper<TypeLocalAttributeLink> typeLocalAttributeLinkQw = new LambdaQueryWrapper<>();
        typeLocalAttributeLinkQw.in(TypeLocalAttributeLink::getLocalAttributeId, localAttributeIds).eq(TypeLocalAttributeLink::getDeleted, DeleteFlagEnum.NO.getValue());
        return list(typeLocalAttributeLinkQw);
    }
}




